package org.example.v4;

import org.example.v4.action.*;
import org.example.v4.enums.Event;
import org.example.v4.enums.OrderState;
import org.example.v4.action.StateAction;

/**
 * OrderStateFactory 类用于创建订单状态实例。
 */
public class OrderStateFactory {
    public static StateAction<OrderStateMachine, Event> getState(OrderState state) {
        switch (state) {
            case PENDING:
                return new PendingStateAction();
            case PAID:
                return new PaidStateAction();
            case SHIPPED:
                return new ShippedStateAction();
            case DELIVERED:
                return new DeliveredStateAction();
            default:
                throw new IllegalArgumentException("未知的状态: " + state);
        }
    }
}
